package com.infinitus.multids.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

@Configuration
public class DataSourceConfig {

	@Bean(name = "primaryDataSource")
	@Qualifier("primaryDataSource")
	@Primary
	@ConfigurationProperties(prefix = "spring.datasource.primary")
	public DataSource primaryDataSource() {
		System.out.println("连接到产品类资讯库");
//		return DataSourceBuilder.create().build();
		DriverManagerDataSource ds = new EncryptedDriverManagerDataSource();
		return ds;
	}

	@Bean(name = "secondaryDataSource")
	@Qualifier("secondaryDataSource")
	@ConfigurationProperties(prefix = "spring.datasource.secondary")
	public DataSource secondaryDataSource() {
		System.out.println("连接到会员&产品库");
		DriverManagerDataSource ds = new EncryptedDriverManagerDataSource();
		return ds;
	}
	
	/*@Bean(name = "thirdDataSource")
	@Qualifier("thirdDataSource")
	@ConfigurationProperties(prefix = "spring.datasource.third")
	public DataSource thirdDataSource() {
		System.out.println("连接到运营中心库");
		DriverManagerDataSource ds = new EncryptedDriverManagerDataSource();
		return ds;
	}*/

}